﻿#include "Student.h"
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
Student::Student():number(0),_class(0),credit(0)
{
	//memset(this,0, sizeof(Student));//不能使用这个，否则会乱码
}

Student::Student(uint32 number):Student()
{
	this->number = number;
}

Student::Student(uint32 number, const std::string& name, const std::string& sex, int _class, std::string Tel, int credit)
	: number(number),name(name),sex(sex), _class(_class), Tel(Tel), credit(credit)
{}

void Student::display()
{
	cout << this->number << "\t" << this->name << "\t" << this->sex << "\t" << this->_class << "\t" << this->Tel << "\t" << this->credit << endl;
}

std::string Student::formatInfo()
{
	stringstream ss;
	ss<< this->number << "\t" << this->name << "\t" << this->sex << "\t" << this->_class << "\t" << this->Tel << "\t" << this->credit << endl;
	return ss.str();
}

void Student::formatWrite(const std::string& str)
{
	stringstream ss(str);
	ss >> this->number  >> this->name  >> this->sex  >> this->_class  >> this->Tel  >> this->credit;
}

bool Student::operator==(const Student& right) const
{
	return this->number == right.number;
}

bool Student::operator>(const Student& right) const
{
	return this->number > right.number;
}

bool Student::operator<(const Student& right) const
{
	return this->number < right.number;
}
